package com.neu.servlet.ww;

import com.neu.service.ww.GoodsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Map;

@WebServlet(name = "ShowGoodServlet",urlPatterns = {"/ShowGoodServlet.do"})
public class ShowGoodServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String g_id=request.getParameter("g_id");
//        System.out.println(g_id);
        GoodsService goodsService=new GoodsService();
        Map<String,Object> goodMap=goodsService.doFindById(g_id);
        HttpSession session=request.getSession();
        if (goodMap!=null){
            session.setAttribute("goodMap",goodMap);
        }
        response.sendRedirect("/HAIGO/showGood.jsp");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
